package com.jsh.jshManage.controller;

import com.jsh.jshManage.datasource.entities.Tenant;
import com.jsh.jshManage.service.tenant.TenantService;
import com.jsh.jshManage.utils.BaseResponseInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author ji sheng hua 华夏ERP
 */
@RestController
@RequestMapping(value = "/tenant")
public class TenantController {
    private Logger logger = LoggerFactory.getLogger(TenantController.class);

    @Resource
    private TenantService tenantService;

    @RequestMapping(value = "/getTenant")
    public BaseResponseInfo getTenantByTenantId(@RequestParam("tenantId") Long tenantId, HttpServletRequest request) {
        BaseResponseInfo res = new BaseResponseInfo();
        try {
            Tenant tenant = tenantService.getTenantByTenantId(tenantId);
            res.code = 200;
            res.data = tenant;
        } catch(Exception e){
            e.printStackTrace();
            res.code = 500;
            res.data = "获取数据失败";
        }
        return res;
    }
}
